<template>
  <div class="hot-container">
    <div class="title">{{ title }}</div>
    <div class="hot-list">
      <div class="hot-item" v-for="(hot, index) in hotList" :key="index" @click="$router.push('/feeds/' + hot.id)">
        <div class="pic">
          <div class="view-count">
            <span class="eye-icon"></span>
            <span class="count">{{ getCount(hot.view_count) }}</span>
          </div>
          <img :src="hot.covers[0].medium_thumbnail_url" alt="" />
        </div>
        <div class="hot-item-title">{{ hot.addresses[0].name }}</div>
        <div class="source">{{ hot.reason_text }}</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    hotList: Array,
    title: String
  },
  methods: {
    getCount(count) {
      if (count < 10000) {
        return count
      } else {
        const re = /^\d+\.?\d?/
        let res = count / 10000 + ''
        return parseFloat(res.match(re)) + 'w'
      }
    }
  }
}
</script>

<style lang="less" scoped>
.hot-container {
  padding: 10px;
  background-color: #fff;

  .title {
    background-color: #fff;
    font-size: 18px;
    font-weight: 600;
    padding-bottom: 20px;
  }

  .hot-list {
    display: flex;
    flex-wrap: nowrap;
    overflow: auto;
    background-color: #fff;

    .hot-item {
      margin-right: 15px;

      &:last-of-type {
        margin-right: 0;
      }

      .pic {
        position: relative;
        width: 40vw;
        height: 25vw;
        overflow: hidden;
        border-radius: 8px;

        .view-count {
          position: absolute;
          bottom: 3px;
          right: 10px;
          display: flex;
          justify-content: space-between;
          align-items: center;
          z-index: 1;

          .eye-icon {
            height: 16px;
            width: 18px;
            background-image: url('@/assets/goImages/9p.png');
            background-size: 100% 100%;
            background-repeat: no-repeat;
          }

          .count {
            font-size: 12px;
            color: #fff;
            line-height: 20px;
            margin-left: 3px;
            font-weight: 600;
          }
        }

        img {
          width: 100%;
          height: 100%;
        }
      }

      .hot-item-title {
        padding: 10px 0;
        font-size: 14px;
        font-weight: 600;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }

      .source {
        color: #76c1e7;
        background-color: #f7f9fa;
        padding: 5px 0 10px;
        padding-left: 10px;
        font-size: 12px;
        font-weight: 500;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
    }
  }
}
</style>
